{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "import random\n",
    "from selenium.webdriver.common.by import By\n",
    "from selenium import webdriver"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception managing MicrosoftEdge: error sending request for url (https://msedgedriver.azureedge.net/LATEST_RELEASE_139_WINDOWS)\n"
     ]
    }
   ],
   "source": [
    "driver = webdriver.Edge()\n",
    "driver.get(\"https://www.digquant.com/account\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def simulate_sendkeys(label,str1):\n",
    "    label.clear()\n",
    "    time.sleep(0.5)\n",
    "    for i in str1:\n",
    "        time.sleep(random.random())\n",
    "        label.send_keys(i)\n",
    "    time.sleep(0.5)\n",
    "    \n",
    "a = driver.find_element(By.XPATH,\"/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div[2]/form/div[1]/div/div/div/input\")\n",
    "simulate_sendkeys(a,\"15819102730\")\n",
    "\n",
    "b = driver.find_element(By.XPATH,\"/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div[2]/form/div[2]/div/div[1]/div/input\")\n",
    "simulate_sendkeys(b,\"DigQuant@01\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#方法一\n",
    "from selenium.webdriver.common.keys import Keys\n",
    "b.send_keys(Keys.ENTER)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#方法二\n",
    "from selenium.webdriver import ActionChains\n",
    "c = driver.find_element(By.XPATH,\"/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div[2]/form/div[3]\")\n",
    "xxx = ActionChains(driver)\n",
    "\n",
    "c = driver.find_element(By.XPATH,\"/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div[2]/form/div[3]\")\n",
    "xxx.click.perform()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
